<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="d3-root"></div>
    <table>
      <tr>
        <td>123</td>
      </tr>
    </table>
    <script src="https://d3js.org/d3.v5.min.js"></script>
    <script>
      const D3 = window.d3;
      // 初始化
      function initD3() {
        // select 选择一个
        // selectAll 选择所有
        const svg = D3.select('#d3-root')
          .append('svg')
          .attr('width', 500)
          .attr('height', 500);
        svg.append('g').attr('a', 'a');
        svg.append('g');
        svg.append('g');
        var matrix = [
          [11975, 5871, 8916, 2868],
          [1951, 10048, 2060, 6171],
          [8010, 16145, 8090, 8045],
          [1013, 990, 940, 6907],
        ];
        // 如果HTML中tr标签的个数少于数组个数,则使用 enter 和 append 操作来补齐 DOM 元素:
        var tr = d3
          .select('body')
          .append('table')
          .selectAll('tr')
          .data(matrix)
          .enter()
          .append('tr');

        var td = tr
          .selectAll('td')
          .data(function (d) {
            return d;
          })
          .enter()
          .append('td')
          .text(function (d) {
            return d;
          });
      }
      initD3();
    </script>

    <script>
      async function fn() {}
      // 返回 promise
      console.log(fn());
    </script>

    <script>
      class Fu {
        name = 'Fu';
        constructor() {
          console.log('Fu');
        }
      }

      class Zi extends Fu {
        constructor() {
          super(); // 当父类中存在构造函数时,必须要先初始化父类(调用父类的构造函数),然后才可以在当前的构造函数中写其他的代码.
          console.log('Zi');
        }
      }

      const obj = new Zi();
    </script>

    <script>
      class Fa {
        test2() {
          console.log('Fa Test2');
        }
      }

      class Demo extends Fa {
        constructor() {
          super();
          console.log('gouzaohanshu');
          this.name = 'Ax';
        }
        test() {
          console.log('test');
        }
      }
      Demo.prototype.test2 = function () {
        console.log(this);
        console.log('test2');
      };
      const demo_obj = new Demo();
      demo_obj.test2 = () => {
        console.log('test222');
      };
      console.log(demo_obj);

      demo_obj.test2();
    </script>
    <script>
      const data = [
        '(113.95110454',
        '23.81190819,',
        '113.95110929382089',
        '23.811916088848506,',
        '113.95111404764178',
        '23.81192398769701,',
        '113.95111880146267',
        '23.811931886545516,',
        '113.95112355528356',
        '23.81193978539402,',
        '113.95112830910445',
        '23.811947684242526,',
        '113.95113306292534',
        '23.81195558309103,',
        '113.95113781674623',
        '23.811963481939536,',
        '113.95114257056711',
        '23.81197138078804,',
        '113.951147324388',
        '23.811979279636546,',
        '113.95115207820889',
        '23.81198717848505,',
        '113.95115683202978',
        '23.811995077333556,',
        '113.95116158585067',
        '23.81200297618206,',
        '113.95116633967156',
        '23.812010875030566,',
        '113.95117109349245',
        '23.81201877387907,',
        '113.95117584731334',
        '23.812026672727576,',
        '113.95118060113423',
        '23.81203457157608,',
        '113.95118535495511',
        '23.812042470424586,',
        '113.951190108776',
        '23.81205036927309,',
        '113.95119486259689',
        '23.812058268121596,',
        '113.95119961641778',
        '23.8120661669701,',
        '113.95120437023867',
        '23.812074065818607,',
        '113.95120912405956',
        '23.81208196466711,',
        '113.95121387788045',
        '23.812089863515617,',
        '113.95121863170134',
        '23.81209776236412,',
        '113.95122338552223',
        '23.812105661212627,',
        '113.95122813934312',
        '23.812113560061132,',
        '113.951232893164',
        '23.812121458909637,',
        '113.9512376469849',
        '23.812129357758142,',
        '113.95124240080578',
        '23.812137256606647,',
        '113.95124715462667',
        '23.812145155455152,',
        '113.95125190844756',
        '23.812153054303657,',
        '113.95125666226845',
        '23.812160953152162,',
        '113.95126141608934',
        '23.812168852000667,',
        '113.95126616991023',
        '23.812176750849172,',
        '113.95127092373112',
        '23.812184649697677,',
        '113.951275677552',
        '23.812192548546182,',
        '113.9512804313729',
        '23.812200447394687,',
        '113.95128518519378',
        '23.812208346243192,',
        '113.95128993901467',
        '23.812216245091697,',
        '113.95129469283556',
        '23.812224143940202,',
        '113.95129944665645',
        '23.812232042788708,',
        '113.95130420047734',
        '23.812239941637213,',
        '113.95130895429823',
        '23.812247840485718,',
        '113.9513404',
        '23.81230009)',
      ];
      const arr = [];
      let currentArr = [];
      const reg = new RegExp('^\\D+|[,]|\\D+$');
      data.forEach((item, key) => {
        if (key % 2) {
          // 奇数
          currentArr[1] = item.replace(reg, '');
        } else {
          // 偶数
          currentArr[0] = item.replace(reg, '');
        }
        if (currentArr.length === 2) {
          arr.push(currentArr);
          currentArr = [];
        }
      });

      console.log(arr);
    </script>

    <script>
      const arar = [1, 2, 3, 4];
      console.log(arar.slice(2)); // 不会改变原始数组
      let v = 0;
      const str = '100*100';
      window.eval(`v=${str}`); // 可以将String转化为JS程序运行
      console.log(v);
    </script>
    <script>
      const c = /^(http:\/\/|https:\/\/)/;
      console.log(c.test('http://www.baidu.com'));
      console.log(c.test('www.baidu.com'));

      const abc = [1, 2, 3, 99, 77, 20];
      console.log(
        abc.sort((a, b) => a - b),
        abc
      );
    </script>

    <script>
      // Object.assign
      const obj1 = { name: 'Ax' };
      const obj2 = { age: 10 };
      const newObj = Object.assign(obj1, obj2); // 与obj1的地址相同,浅拷贝到obj1里边
      console.log(newObj, newObj === obj1, obj1);
    </script>
  </body>
</html>
